package com.ruoyi.web.controller.application;

import com.hust.domain.ApportionResult;
import com.hust.service.IApportionService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;

@RestController
@CrossOrigin
@RequestMapping("/application/apportion")
public class ApportionController extends BaseController {
    @Resource
    private IApportionService apportionService;

    @RequestMapping("/calculate")
    //@Log(title = "请求指定条件的调度方案", businessType = BusinessType.QUERY)
    public AjaxResult calculate(@RequestBody Date date) {
        ApportionResult result = apportionService.calculate(date);

        if (result == null) {
            return AjaxResult.error("计算失败");
        } else {
            AjaxResult ajax = AjaxResult.success();
            ajax.put("data", result);
            return ajax;
        }
    }

}
